package record;

import java.io.Serializable;

/**
 * A class that represents an address.
 * @author Stephan Jossie
 * @author Jacob Freemyer
 *
 */
@SuppressWarnings("serial")
public class Address implements Serializable
{
	/**
	 * Street number
	 */
	private String streetNumber;
	
	/**
	 * Street name
	 */
	private String street;
	
	/**
	 * Second line for specifying residence information
	 */
	private String secondAddressLine;
	
	/**
	 * Zipcode
	 */
	private String zipcode;
	
	/**
	 * State
	 */
	private String state;
	
	/**
	 * City
	 */
	private String city;
	
	/**
	 * Name of resident at address
	 */
	private String name;
	
	/**
	 * Creates an instance of Address that holds address information of a user.
	 * @param pName
	 * 		Name of the person that lives at the address.
	 * @param pStreetNumber
	 * 		Street number of the address.
	 * @param pStreet
	 * 		Street to which the person lives on.
	 * @param pSecondAddressLine
	 * 		The second address line that is used for Apt,PO Box,ect.
	 * @param pCity
	 * 		The city in which the address is located.
	 * @param pState
	 * 		The state in which the address is located.
	 * @param pZipcode
	 * 		The zipcode of the address.
	 */
	public Address(String pName,String pStreetNumber, String pStreet, String pSecondAddressLine,
			       String pCity, String pState,String pZipcode)
	{
		streetNumber = pStreetNumber;
		street = pStreet;
		secondAddressLine = pSecondAddressLine;
		zipcode = pZipcode;
		state = pState;
		city = pCity;
		name = pName;
		
	}
	
	/**
	 * Creates and Address instance without a secondary address line.
	 * @param pName
	 * 		Name of the person that lives at the address.
	 * @param pStreetNumber
	 * 		Street number of the address.
	 * @param pStreet
	 * 		Street to which the person lives on.
	 * @param pCity
	 * 		The city in which the address is located.
	 * @param pState
	 * 		The state in which the address is located.
	 * @param pZipcode
	 * 		The zipcode of the address.
	 */
	public Address(String pName,String pStreetNumber, String pStreet,
			        String pCity, String pState,String pZipcode)
	{
		streetNumber = pStreetNumber;
		street = pStreet;
		secondAddressLine = "";
		zipcode = pZipcode;
		state = pState;
		city = pCity;
		name = pName;
	}

	/**
	 * Getter to get the street number of the address.
	 * @return
	 * 		Street number
	 */
	public String getStreetNumber() {
		return streetNumber;
	}

	/**
	 * Setter to change the street number.
	 * @param streetNumber
	 * 		Street number to change the current street number to.
	 */
	public void setStreetNumber(String streetNumber) {
		this.streetNumber = streetNumber;
	}

	/**
	 * Getter to get the street of the address.
	 * @return
	 * 		The street
	 */
	public String getStreet() {
		return street;
	}

	/**
	 * Setter to set the street of the address.
	 * @param street
	 * 		Street to change the current street to.
	 */
	public void setStreet(String street) {
		this.street = street;
	}

	/**
	 * Getter to get the secondary address line of the address.
	 * @return
	 * 		The secondary address
	 */
	public String getSecondAddressLine() {
		return secondAddressLine;
	}

	/**
	 * Setter to set the secondary address line of the address
	 * @param secondAddressLine
	 * 		The new secondary address line to change the current one.
	 */
	public void setSecondAddressLine(String secondAddressLine) {
		this.secondAddressLine = secondAddressLine;
	}

	/**
	 * Getter to get the zipcode of the address.
	 * @return
	 * 		The zipcode of the address
	 */
	public String getZipcode() {
		return zipcode;
	}

	/**
	 * Seeter to set the zipcode fo the address.
	 * @param zipcode
	 * 		The zipcode to change the current zipcode to.
	 */
	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	/**
	 * Getter to get the State the address is located in.
	 * @return
	 * 		The State the address is in.
	 */
	public String getState() {
		return state;
	}

	/**
	 * Setter to set the State of the address
	 * @param state
	 * 		State to set State of address to.
	 */
	public void setState(String state) {
		this.state = state;
	}

	/**
	 * Getter to get the City of the address
	 * @return
	 * 		The City of the address.
	 */
	public String getCity() {
		return city;
	}

	/**
	 * Setter to set the City of the address.
	 * @param city
	 * 		City in which to change the current city to.
	 */
	public void setCity(String city) {
		this.city = city;
	}

	/**
	 * Getter to get the name of the person at the address
	 * @return
	 * 		Name of person at the address
	 */
	public String getName() {
		return name;
	}

	/**
	 * Setter to set the name of the person at the address
	 * @param name
	 * 		The name of the person at the address
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * <Name>
	 * <Street Number> <Street>
	 * <Secondary Address Line>
	 * <City>, <State> <Zipcode>
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(name + String.format("%n"));
		builder.append(streetNumber + " " + street + " " + String.format("%n"));
		if(!secondAddressLine.equals(""))
		{
			builder.append(secondAddressLine + String.format("%n"));
		}
		builder.append(city + ", " + state + " " + zipcode);
		return builder.toString();
	}
	
	
	
}
